﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Xml.Linq;

namespace HigLabo.Net.Twitter
{
    public partial class TwitterClient
    {
        /// <summary>
        /// 
        /// </summary>
        /// <param name="callback"></param>
        public void GetDirectMessageList(Action<DirectMessageCollection> callback)
        {
            this.GetDirectMessageList(null as GetDirectMessageListCommand, callback);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="command"></param>
        /// <param name="callback"></param>
        public void GetDirectMessageList(GetDirectMessageListCommand command, Action<DirectMessageCollection> callback)
        {
            this.GetResultText(TwitterApiUrl.Version1_1.DirectMessages.DirectMessagesUrl, command, json => callback(new DirectMessageCollection(json)));
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="callback"></param>
        public void GetDirectMessageListSent(Action<DirectMessageCollection> callback)
        {
            this.GetDirectMessageListSent(null as GetDirectMessageListCommand, callback);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="command"></param>
        /// <param name="callback"></param>
        public void GetDirectMessageListSent(GetDirectMessageListSentCommand command, Action<DirectMessageCollection> callback)
        {
            this.GetResultText(TwitterApiUrl.Version1_1.DirectMessages.DirectMessagesSentUrl, command, json => callback(new DirectMessageCollection(json)));
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="id"></param>
        /// <param name="callback"></param>
        public void DestroyDirectMessage(Int64 id, Action<DirectMessage> callback)
        {
            this.DestroyDirectMessage(new DestroyDirectMessageCommand() { ID = id }, callback);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="command"></param>
        /// <param name="callback"></param>
        public void DestroyDirectMessage(DestroyDirectMessageCommand command, Action<DirectMessage> callback)
        {
            this.GetResultText(HttpMethodName.Post, TwitterApiUrl.Version1_1.DirectMessages.DestroyFormatUrl, command, json => callback(new DirectMessage(json)));
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="userID"></param>
        /// <param name="text"></param>
        /// <param name="callback"></param>
        public void NewDirectMessage(Int64 userID, String text, Action<DirectMessage> callback)
        {
            var cm = new NewDirectMessageCommand();
            cm.UserID = userID;
            cm.Text = text;
            this.NewDirectMessage(cm, callback);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="command"></param>
        /// <param name="callback"></param>
        public void NewDirectMessage(NewDirectMessageCommand command, Action<DirectMessage> callback)
        {
            this.GetResultText(HttpMethodName.Post, TwitterApiUrl.Version1_1.DirectMessages.NewUrl, command, json => callback(new DirectMessage(json)));
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="id"></param>
        /// <param name="callback"></param>
        public void GetDirectMessagesByID(Int64 id, Action<DirectMessageCollection> callback)
        {
            this.GetDirectMessagesByID(new GetDirectMessageCommand() { ID = id }, callback);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="command"></param>
        /// <param name="callback"></param>
        public void GetDirectMessagesByID(GetDirectMessageCommand command, Action<DirectMessageCollection> callback)
        {
            this.GetResultText(TwitterApiUrl.Version1_1.DirectMessages.GetDirectMessagesShowUrl, command, json => callback(new DirectMessageCollection(json)));
        }
    }
}
